package com.archaeanx.libx;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.archeanx.libx.adapter.binding.OnItemClickListener;
import com.archeanx.libx.adapter.binding.XRvBindingHolder;
import com.archeanx.libx.util.ToastUtil;
import com.archeanx.libx.widget.dialog.XLoadingDialog;
import com.archeanx.libx.adapter.divider.XRvVerticalDivider;

import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private static final int ITEM_1 = 111;
    private static final int ITEM_2 = 222;
    private static final int ITEM_3 = 333;
    private static final int ITEM_4 = 444;
    private static final int ITEM_5 = 555;
    private static final int ITEM_6 = 666;
    private static final int ITEM_7 = 777;

    static List<Object> lists = new ArrayList<>();

    static {
        lists.add(ITEM_1);
        lists.add(ITEM_2);
        lists.add(ITEM_2);
        lists.add(ITEM_2);
        lists.add(ITEM_2);
        lists.add(ITEM_2);
        lists.add(ITEM_2);
        lists.add(ITEM_2);
        lists.add(ITEM_2);
        lists.add(ITEM_2);
        lists.add(ITEM_2);
        lists.add(ITEM_2);
        lists.add(ITEM_3);
        lists.add(ITEM_4);
        lists.add(ITEM_4);
        lists.add(ITEM_4);
        lists.add(ITEM_4);
        lists.add(ITEM_4);
        lists.add(ITEM_4);
        lists.add(ITEM_4);
        lists.add(ITEM_5);
        lists.add(ITEM_5);
        lists.add(ITEM_5);
        lists.add(ITEM_5);
        lists.add(ITEM_5);
        lists.add(ITEM_5);
        lists.add(ITEM_5);
        lists.add(ITEM_5);
        lists.add(ITEM_5);
        lists.add(ITEM_6);
        lists.add(ITEM_6);
        lists.add(ITEM_6);
        lists.add(ITEM_6);
        lists.add(ITEM_6);
        lists.add(ITEM_6);
        lists.add(ITEM_7);
        lists.add(ITEM_7);
        lists.add(ITEM_7);
        lists.add(ITEM_7);
        lists.add(ITEM_7);
        lists.add(ITEM_7);
        lists.add(ITEM_7);
        lists.add(ITEM_7);
        lists.add(ITEM_7);
    }

    int dialogIndex = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //  AppUpdateManager.getInstance().init(this);


//        XRvSingleAdapter<Integer> adapter= new XRvSingleAdapter<>(R.layout.item_1);
//
//        adapter.setOnRvSignleBindViewListener(new XRvSingleAdapter.OnRvSignleBindViewListener<Integer>() {
//            @Override
//            public void onBindViewHolderToStatus(@NonNull XRvViewHolder holder, int position, Integer o) {
//
//            }
//        });


        Log.e("showLogn_begin", Long.toString(System.currentTimeMillis()));
        ToastUtil.init(this);
        ToastUtil.show("aljfsdlfjalsjljljljagl;difjasnc");
        ToastUtil.show("aljfsdlfjalsjljljljagl;safasfdifjasnc");
        ToastUtil.show("aljfsdlfjalsjljsadfasfljljagl;difjasnc");
        ToastUtil.show("aljfsdlfjalsjljljasfddasfljagl;difjasnc");
        ToastUtil.show("aljfsdlfjalsjljlasfasjljagl;difjasnc");

        Log.e("showLogn_endee", Long.toString(System.currentTimeMillis()));

        final TextView toast2 = findViewById(R.id.am_show_toast2);
        final XLoadingDialog xLoadingDialog = new XLoadingDialog(this);





        RecyclerView recyclerView = findViewById(R.id.am_rv);
        recyclerView.setItemViewCacheSize(10);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        recyclerView.addItemDecoration(new XRvVerticalDivider.Builder(this).build());
        final TestAdapter3 adapter = new TestAdapter3();

        recyclerView.setAdapter(adapter);

        List<Integer> list = new ArrayList<Integer>();
        for (int i = 0; i < 100; i++) {
            list.add(i);
        }

        adapter.setDatas(list, true);
        adapter.showNoMoreData(true);

        adapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(@NotNull View view, @NotNull XRvBindingHolder holder, int position) {
            }
        });

        findViewById(R.id.am_show_toast).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                adapter.showNoMoreData(false);
            }
        });

        findViewById(R.id.am_show_toast2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                adapter.showNoMoreData(true);
            }
        });
    }


}
